fix(cli): spec-compliant terminal image rendering + Windows clipboard… - #974
fix(cli): spec-compliant terminal image rendering + Windows clipboard…#974smarpitm wants to merge 2 commits into
Conversation
|
Good catches on But Before this can be ported: either convert compressed images to PNG before the kitty path (simplest, since 100 is the only guaranteed-compatible non-raw format), or drop the fabricated format ids and stick to 100/24/32 as the spec actually defines, deriving alpha/no-alpha via raw pixel mode if you want to avoid re-encoding. The terminal-detection additions (WezTerm/Ghostty/Warp/Konsole) and the Windows |
…G payloads getKittyFormat() now always returns 100 (PNG) — the only format id that all kitty-protocol terminals guarantee. Non-PNG payloads (JPEG, WebP, GIF) are converted to PNG via Jimp before transmission, so the bytes always match f=100. This prevents terminals from silently dropping images due to fabricated format ids (101-104) that don't exist in the kitty spec. renderInlineImage() is now async to support the Jimp conversion step. image-block.tsx and image-card.tsx updated to handle async with useEffect + state. New tests validate that the escape sequence uses only spec-compliant format ids (f=24|32|100) across all media types, and that no fabricated ids (101-104) appear in any chunk. 🤖 Generated with Codebuff Co-Authored-By: Codebuff <noreply@codebuff.com>
What
Fixes terminal inline image rendering so attached photos display correctly in kitty-capable terminals, and hardens Windows clipboard image paste.
Why
Photos attached via
/imageor Ctrl+V could render "distorted":m=0terminator and every chunk repeateda=T/full control data, so terminals treated each chunk as a new image (fragmented display). The format id was also hardcoded tof=100(PNG) even for the JPEG payloads the compression step produces.sizeparam sent the base64 length instead of the decoded byte length (minus padding).powershell.exe(nopwshfallback).Changes
cli/src/utils/terminal-images.ts— spec-compliant kitty chunking (m=0on the last chunk, control data only on the first), format id derived from the real media type, iTerm2size= decoded bytes, detection for WezTerm/Ghostty/Warp/Konsole (case-insensitive).cli/src/utils/clipboard-image.ts—pwshfallback whenpowershell.exeis missing, normalized string output.cli/src/components/blocks/image-block.tsx,image-card.tsx— passmediaTypeto the renderer.terminal-images.test.ts(sequence conformance against the kitty spec),image-pipeline-integrity.test.ts(verifies image processing never corrupts payloads).test/setup-scm-loader.ts— no-op stub sobun testin theclipackage works in the public mirror (referenced bycli/bunfig.tomlbut missing from the public repo).Validation
bun run typecheck(cli) clean.Note
DeepSeek V4 Flash (the default model) is
multimodal: falseand reads images via the server-side describe pipeline — for best results with photos, use MiniMax M3 / GPT-5.6 Luna / MiMo 2.5.